﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using WeiSha.Core.Param.Method;

namespace WeiSha.Core
{
	// Token: 0x0200001A RID: 26
	public class App
	{
		// Token: 0x17000020 RID: 32
		// (get) Token: 0x06000091 RID: 145 RVA: 0x00005114 File Offset: 0x00003314
		public static App Get
		{
			get
			{
				return App._get;
			}
		}

		// Token: 0x17000021 RID: 33
		// (get) Token: 0x06000092 RID: 146 RVA: 0x0000512C File Offset: 0x0000332C
		public static int Span
		{
			get
			{
				bool flag = App._span == null;
				if (flag)
				{
					int num;
					App._span = new int?(int.TryParse(App.Attr("span"), out num) ? num : 0);
				}
				int? span = App._span;
				int num2 = 0;
				bool flag2 = (span.GetValueOrDefault() < num2) & (span != null);
				if (flag2)
				{
					App._span = new int?(0);
				}
				return App._span.Value;
			}
		}

		// Token: 0x17000022 RID: 34
		// (get) Token: 0x06000093 RID: 147 RVA: 0x000051A8 File Offset: 0x000033A8
		public static AppStageEnum Stage
		{
			get
			{
				bool flag = App.Span > 0;
				AppStageEnum appStageEnum;
				if (flag)
				{
					appStageEnum = AppStageEnum.Trial;
				}
				else
				{
					AppStageEnum stageItem = App.getStageItem(App.Attr("stage"));
					appStageEnum = stageItem;
				}
				return appStageEnum;
			}
		}

		// Token: 0x06000094 RID: 148 RVA: 0x000051DC File Offset: 0x000033DC
		private static AppStageEnum getStageItem(string name)
		{
			AppStageEnum appStageEnum2;
			try
			{
				foreach (object obj in Enum.GetValues(typeof(AppStageEnum)))
				{
					AppStageEnum appStageEnum = (AppStageEnum)obj;
					bool flag = appStageEnum.ToString().Equals(name, StringComparison.CurrentCultureIgnoreCase);
					if (flag)
					{
						return appStageEnum;
					}
				}
				appStageEnum2 = (AppStageEnum)Enum.Parse(typeof(AppStageEnum), name);
			}
			catch
			{
				appStageEnum2 = AppStageEnum.Beta;
			}
			return appStageEnum2;
		}

		// Token: 0x17000023 RID: 35
		// (get) Token: 0x06000095 RID: 149 RVA: 0x00005288 File Offset: 0x00003488
		public static string Key
		{
			get
			{
				bool flag = string.IsNullOrWhiteSpace(App._key);
				if (flag)
				{
					App._key = App.Attr("key");
				}
				return App._key;
			}
		}

		// Token: 0x06000096 RID: 150 RVA: 0x00002EA2 File Offset: 0x000010A2
		private App()
		{
		}

		// Token: 0x17000024 RID: 36
		public ConvertToAnyValue this[string key]
		{
			get
			{
				return new ConvertToAnyValue(PlatformInfoHandler.Node("App").ItemValue(key));
			}
		}

		// Token: 0x06000098 RID: 152 RVA: 0x000052E4 File Offset: 0x000034E4
		public static string Attr(string key)
		{
			bool flag = string.IsNullOrWhiteSpace(key);
			string text;
			if (flag)
			{
				text = string.Empty;
			}
			else
			{
				PlatformInfoHandler.SiteInfoHandlerParaNode siteInfoHandlerParaNode = PlatformInfoHandler.Node("App");
				text = ((siteInfoHandlerParaNode != null) ? siteInfoHandlerParaNode.Attribute(key) : string.Empty);
			}
			return text;
		}

		// Token: 0x17000025 RID: 37
		// (get) Token: 0x06000099 RID: 153 RVA: 0x00005324 File Offset: 0x00003524
		public static Dictionary<string, string> Details
		{
			get
			{
				object details_lock = App._details_lock;
				Dictionary<string, string> dictionary2;
				lock (details_lock)
				{
					Dictionary<string, string> dictionary = new Dictionary<string, string>();
					Assembly executingAssembly = Assembly.GetExecutingAssembly();
					object[] customAttributes = executingAssembly.GetCustomAttributes(false);
					License value = License.Value;
					bool flag2 = !value.IsLicense;
					if (flag2)
					{
						foreach (object obj in customAttributes)
						{
							bool flag3 = obj is AssemblyProductAttribute;
							if (flag3)
							{
								dictionary.Add("产品名称", ((AssemblyProductAttribute)obj).Product);
							}
						}
						foreach (object obj2 in customAttributes)
						{
							bool flag4 = obj2 is AssemblyDescriptionAttribute;
							if (flag4)
							{
								dictionary.Add("产品介绍", ((AssemblyDescriptionAttribute)obj2).Description);
							}
						}
						foreach (object obj3 in customAttributes)
						{
							bool flag5 = obj3 is AssemblyCompanyAttribute;
							if (flag5)
							{
								dictionary.Add("开发团队", ((AssemblyCompanyAttribute)obj3).Company);
							}
						}
						foreach (object obj4 in customAttributes)
						{
							bool flag6 = obj4 is AssemblyTitleAttribute;
							if (flag6)
							{
								dictionary.Add("团队介绍", ((AssemblyTitleAttribute)obj4).Title);
							}
						}
						foreach (object obj5 in customAttributes)
						{
							bool flag7 = obj5 is AssemblyConfigurationAttribute;
							if (flag7)
							{
								dictionary.Add("核心开发者", ((AssemblyConfigurationAttribute)obj5).Configuration);
							}
						}
						foreach (object obj6 in customAttributes)
						{
							bool flag8 = obj6 is AssemblyCopyrightAttribute;
							if (flag8)
							{
								dictionary.Add("版权所有", ((AssemblyCopyrightAttribute)obj6).Copyright);
							}
						}
						foreach (object obj7 in customAttributes)
						{
							bool flag9 = obj7 is AssemblyTrademarkAttribute;
							if (flag9)
							{
								dictionary.Add("商标", ((AssemblyTrademarkAttribute)obj7).Trademark);
							}
						}
					}
					else
					{
						dictionary.Add("产品名称", Copyright.Value("product"));
						dictionary.Add("产品介绍", Copyright.Value("intro"));
						dictionary.Add("开发团队", Copyright.Value("company"));
						dictionary.Add("团队介绍", Copyright.Value("title"));
						dictionary.Add("核心开发者", Copyright.Value("email"));
						dictionary.Add("版权所有", Copyright.Value("powerby"));
						dictionary.Add("商标", Copyright.Value("abbr"));
					}
					string text = AppDomain.CurrentDomain.BaseDirectory + "\\bin\\Song.WebSite.dll";
					Assembly assembly = Assembly.LoadFrom(text);
					Version version = assembly.GetName().Version;
					dictionary.Add("版本号", version.Major.ToString() + "." + version.Minor.ToString());
					dictionary.Add("内部版本号", version.ToString());
					dictionary.Add("发布状态", App.Stage.ToString());
					dictionary.Add("发布时间", File.GetLastWriteTime(text).ToString("yyyy-MM-dd HH:mm:ss"));
					dictionary2 = dictionary;
				}
				return dictionary2;
			}
		}

		// Token: 0x0600009A RID: 154 RVA: 0x000056EC File Offset: 0x000038EC
		public static string DetailGet(string key)
		{
			foreach (KeyValuePair<string, string> keyValuePair in App.Details)
			{
				bool flag = keyValuePair.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase);
				if (flag)
				{
					return keyValuePair.Value;
				}
			}
			return string.Empty;
		}

		// Token: 0x04000025 RID: 37
		private static readonly App _get = new App();

		// Token: 0x04000026 RID: 38
		private static int? _span = null;

		// Token: 0x04000027 RID: 39
		private static string _key = string.Empty;

		// Token: 0x04000028 RID: 40
		private static object _details_lock = new object();
	}
}
